package com.example.hello_app.controller;

import com.example.hello_app.model.AppResponse;
import com.example.hello_app.model.User;
import com.example.hello_app.repository.UserRepository;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Tag(name = "用户管理", description = "用户相关接口")
public class UserController {

    private static final Logger log = LoggerFactory.getLogger(UserController.class);
    @Autowired
    private UserRepository userRepository;

    @GetMapping("/users")
    @Operation(summary = "获取用户列表", description = "返回所有用户信息")
    public AppResponse<Iterable<User>> getAllUsers() {
        log.warn("getAllUsers");
        return AppResponse.success(userRepository.findAll());
    }

}
